function [CurrentTrueList] = Ddavid_add_points_by_knn(TrueLabel, SampledTrueLabel, K, KNNList)

% [CurrentTrueList] = Ddavid_add_points_by_knn(TrueLabel, SampledTrueLabel, KNNList, K)
%
% <Input>
% TrueLabel: [n*1], the value is {-1, 1}, the real answer of this label
% SampledTrueLabel: [n*1], {0, 1}, 1 means the points is considered as this label
% K: The K value of KNN
% KNNList: The KNN List (for saving time)
%
% <Output>
% CurrentTrueList: [n*1], {0, 1}, 1 means the instance is considered as
%                                 true

disp('Ddavid_add_points_by_knn');

SampledTrueLabelSize = sum(SampledTrueLabel == 1);

% KNN
KNNLabel = SampledTrueLabel(KNNList(:, :));
    
% Add points to CurrentTrueList by KNN
CurrentTrueList = (sum(KNNLabel, 2) > (K / 2)) | SampledTrueLabel;
CurrentTrueListSize = sum(CurrentTrueList == 1);

AddedPointNumber = sum((CurrentTrueList == 1) & (SampledTrueLabel == 0));
CorrectPointNumber = sum((CurrentTrueList == 1) & (SampledTrueLabel == 0) & (TrueLabel == 1));

disp(['CurrentTrueList Size = ' num2str(SampledTrueLabelSize) ' -> ' num2str(CurrentTrueListSize) ', ' num2str(CorrectPointNumber) '/' num2str(AddedPointNumber) ' = ' num2str(CorrectPointNumber / AddedPointNumber * 100) '%']);
